package com.example.hospital_208.service.impl;

import com.example.hospital_208.dao.MedicalRecordMapper;
import com.example.hospital_208.po.MedicalRecord;
import com.example.hospital_208.service.MedicalRecordService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MedicalRecordServiceImpl implements MedicalRecordService {

    private final MedicalRecordMapper medicalRecordMapper;

    public MedicalRecordServiceImpl(MedicalRecordMapper medicalRecordMapper) {
        this.medicalRecordMapper = medicalRecordMapper;
    }

    @Override
    public List<MedicalRecord> listMedicalRecords() {
        return medicalRecordMapper.findAllMedicalRecords();
    }
    @Override
    public MedicalRecord getMedicalRecordByUserId(Integer userId) {
        return medicalRecordMapper.findMedicalRecordByUserId(userId);
    }
    @Override
    public MedicalRecord getMedicalRecordById(Integer recordId) {
        return medicalRecordMapper.findMedicalRecordById(recordId);
    }

    @Override
    public int addMedicalRecord(MedicalRecord medicalRecord) {
        return medicalRecordMapper.insertMedicalRecord(medicalRecord);
    }

    @Override
    public int editMedicalRecord(MedicalRecord medicalRecord) {
        return medicalRecordMapper.updateMedicalRecord(medicalRecord);
    }

    @Override
    public int removeMedicalRecord(Integer recordId) {
        return medicalRecordMapper.deleteMedicalRecordById(recordId);
    }
}